//
//  HWMineTableProtocol.swift
//  HWanGame
//
//  Created by 王昌健 on 2021/12/22.
//  Copyright © 2021 94Wan. All rights reserved.
//

import UIKit

class HWMineTableProtocol: NSObject {
    var model:HWMineModel?
    var showBadge = false
    /// 功能
    var navClick:((_ model:HWMineNavModel)->())?
    /// 点击游戏
    var itemButtonClick:((_ id:String)->())?
    /// 更多
    var moreButtonClick:(()->())?
    /// 消息
    var messageButtonClick:(()->())?
    /// 设置
    var settingButtonClick:(()->())?
    /// 签到
    var signButtonClick:(()->())?
    /// 开通Vip
    var openVipButtonClick:(()->())?
    /// 个人信息
    var mineInfoButtonClick:(()->())?
    /// 卡券
    var cardButtonClick:(()->())?
    /// 钱包
    var walletButtonClick:(()->())?
    /// 我的游戏
    var myGameButtonClick:(()->())?
    /// 我的关注
    var myFollowButtonClick:(()->())?
}

extension HWMineTableProtocol:UITableViewDelegate,UITableViewDataSource {
    
    func numberOfSections(in tableView: UITableView) -> Int {
        if model != nil {
            return 1
        }
        return 0
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if model != nil {
            return 1
        }
        return 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = HWMineCell.cellWithTableView(tableView: tableView)
        cell.model = model
        cell.showBadge = self.showBadge
        cell.messageButtonClick = {
            self.messageButtonClick?()
        }
        
        cell.settingButtonClick = {
            self.settingButtonClick?()
        }
        
        cell.signButtonClick = {
            self.signButtonClick?()
        }
        
        cell.openVipButtonClick = {
            self.openVipButtonClick?()
        }
        
        cell.mineInfoButtonClick = {
            self.mineInfoButtonClick?()
        }
        
        cell.navClick = {
            mod in
            self.navClick?(mod)
        }
        cell.itemButtonClick = {
            id in
            self.itemButtonClick?(id)
        }
        cell.moreButtonClick = {
            self.moreButtonClick?()
        }
        
        cell.cardButtonClick = {
            self.cardButtonClick?()
        }
        cell.walletButtonClick = {
            self.walletButtonClick?()
        }
        
        cell.myGameButtonClick = {
            self.myGameButtonClick?()
        }
        
        cell.myFollowButtonClick = {
            self.myFollowButtonClick?()
        }
        return cell
    }
}
